﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;

namespace BestEasyCMS.Web.MvcUI.Helper
{
    public class DataHelper
    {
        /// <summary>
        /// 获取结果集
        /// </summary>
        /// <param name="rel">状态</param>
        /// <param name="msg">提示信息</param>
        /// <param name="data">数据集</param>
        /// <returns></returns>
        public static Dictionary<string, object> GetResult(bool rel, string msg, object data)
        {
            return new Dictionary<string, object> { { "rel", rel }, { "msg", msg }, { "obj", data } };
        }
        /// <summary>
        /// 获取结果集
        /// </summary>
        /// <param name="rel">状态</param>
        /// <param name="data">数据集</param>
        /// <returns></returns>
        public static Dictionary<string, object> GetResult(bool rel, object data)
        {
            return new Dictionary<string, object> { { "rel", rel }, { "obj", data } };
        }
        /// <summary>
        /// 获取JsonString
        /// </summary>
        /// <param name="rel">状态</param>
        /// <param name="msg">提示信息</param>
        /// <param name="data">数据集</param>
        /// <returns></returns>
        public static string GetJson(bool rel, string msg, object data)
        {
            return JsonConvert.SerializeObject(new Dictionary<string, object> { { "rel", rel }, { "msg", msg }, { "obj", data } });
        }
    }
}